<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
	body{height:1000px;}
	div {width:100px;height:100px;background-color:red; position: absolute;}
	</style>
	<script>
	window.onload = function (){
	//注意 ：clientX、clientY是相对于 可视区 的值(不带px的数字)
	/*	function fn( ev ){
			var ev = ev || event;
			alert(ev.clientX + ',' + ev.clientY);
		}
		document.onclick = fn;
	*/
		var oDiv = document.getElementById('div1');

		document.onmousemove = function (ev){
			var ev = ev || event;
			var scroll_Top = document.documentElement.scrollTop || document.body.scrollTop;	
			//div位置 = 鼠标相对于可视区的位置 +　滚动条滚动距离
			oDiv.style.left = ev.clientX + 'px';		//同理，如果滚动条是在x轴上，那么我们就在这里加上滚动条滚动距离
			oDiv.style.top = ev.clientY + scroll_Top + 'px';
		}
	}
	</script>
</head>
<body>
	<div id="div1"></div>
	
</body>
</html>